package com.michael.common.error.code;

import com.michael.common.error.exception.BizException;
import com.michael.common.result.BaseResult;

import java.util.Objects;

public enum BizCode {
    SUCCESS(0, "svc.success", "success"),
    SYS_FATAL_ERR(9900, "svc.sys_software_err", "sever software  err"),
    SERVER_ERR(9901, "svc.sever_logic_err", "sever logic err"),
    JSON_ENCODING_ERR(9902, "svc.json_codec_err", "json codec err"),
    REQUEST_BODY_NONE(9903, "svc.request_body_none", "request body null"),

    PARAMETER_ERR(9909, "svc.parameter.err", "parameter.err"),
    APP_REVISION_ERR(9910, "svc.apprevision.err", "app版本校验失败"),

    FALLBACK_ERROR(9911, "third.party.fallback.err", "下游fallback异常"),
    BUSINESS_ERROR(9912, "third.party.business.err", "下游业务异常"),
    UNKNOWN_ERROR(9913, "third.party.unknown.err", "下游未知异常"),

    TOKEN_ERROR(10001, "svc.login_error", "登录异常"),
    ORDER_NOT_EXISTS(10007, "svc.order_not_exist", "订单不存在"),

    SERVER_ERROR(10008, "svc.server_error", "服务器错误"),

    ORDER_STATUS_ERROR(10009, "svc.order_status_error", "订单状态不一致"),

    SIGN_ERROR(10010, "svc.sign_error", "签名错误"),

    CUSTOMER_EXCEPTION(10015, "svc.customer_exception", ""),

    DB_OPERATE_ERROR(10017, "db_operate_error", "数据库操作错误"),

    CACHE_OPERATE_ERROR(10018, "cache_operate_error", "缓存操作错误"),

    CARPOOLING_PARAM_ERROR(20002, "carpooling_param_error", "拼车参数错误"),

    BLACK_DRIVER(20007, "black_driver", "司机被拉黑"),

    PRE_UNREGISTER_DRIVER_PICKUP_ERROR(20011, "pre_unregister_driver_pickup_error", "预销户不能接单"),

    LOCATION_LIMIT_ERROR(21104, "svc.location_limit_error", "系统检测到您当前距离发货地过远，无法确认到达!如有疑问，请致电客服!"),

    PERSON_ITEM_INFO_EMPTY(20010, "person_item_info_empty", "请上传本人自拍照"),

    CAR_ITEM_INFO_EMPTY(20011, "car_item_info_empty", "请上传车辆照片"),

    GOODS_ITEM_INFO_EMPTY(20012, "goods_item_info_empty", "请上传货物照片"),

    ORDER_INFO_ERROR(20003, "order_info_error", "订单信息缺少"),

    BILL_EMPTY_ERROR(20001, "bill_empty_error", "账单信息为空"),

    DRIVER_PICK_UP_WITHOUT_OFFER_PRICE(93, "driver_pick_up_without_offer_price", "司机原价接单"),

    DRIVER_CANCEL_MARKUP(94, "driver_cancel_markup", "司机手动撤回"),

    DRIVER_OFFER_TIME_OVER_RANGE(95, "driver_offer_time_over_range", "司机有效期的出价次数超过限制"),

    MARKUP_SUCCESS_DRIVER_PICKUP_TIMEOUT(97, "markup_success_driver_pickup_timeout", "客户同意加价，司机接单超时"),

    TRUNK_MARKUP_ORDER_AB_CHECK_ERROR(98, "trunk_ab_check_error", "该大车订单不在ab内"),

    MARKUP_ORDER_AB_CHECK_ERROR(99, "ab_check_error", "该订单不在ab内"),

    MARKUP_ORDER_STATUS_ERROR(100, "order_status_error", "订单已经被抢走了"),

    MARKUP_ORDER_PICKUP_DURATION_TOO_SHORT(101, "pickup_duration_too_short", "离订单创建时间过短，不可加价"),

    MARKUP_ORDER_APPLY_TIMES_OVER_RANGE(102, "apply_time_over_range", "订单申请加价次数超过限制"),

    MARKUP_ORDER_DRIVER_APPLY_TIMES_OVER_RANGE(103, "driver_apply_time_over_range", "司机申请加价次数超过限制"),

    MARKUP_ORDER_DRIVER_APPLY_RECORD_STATUS_CHECK_ERROR(104, "driver_apply_record_status_check_error", "该订单已有其他司机加价记录"),

    MARKUP_ORDER_APPLY_RECORD_STATUS_CHECK_ERROR(105, "apply_record_status_check_error", "已有司机抢先加价"),

    MARKUP_ORDER_TIPS_CHECK_ERROR(106, "tips_check_error", "客户已主动加价"),

    MARKUP_ORDER_PRICE_CHECK_ERROR(107, "price_check_error", "订单金额不符合加价条件"),

    MARKUP_ORDER_FEEDBACK_RESULT_ERROR(108, "feedback_result_error", "反馈结果非法"),

    MARKUP_ORDER_FEEDBACK_RECORD_MISSING(109, "feedback_record_missing", "无该司机加价记录"),

    MARKUP_ORDER_FEEDBACK_RECORD_DUPLICATION(110, "feedback_record_duplication", "其他司机加价已成功，无法操作该记录"),

    MARKUP_ORDER_FEEDBACK_RECORD_FAIL(111, "feedback_record_fail", "司机加价已成功，请勿重复反馈"),

    MARKUP_ORDER_APPLY_REJECTED(112, "reject_markup_record", "加价失败客户未接受申请"),

    MARKUP_ORDER_TIMEOUT_CLOSE(113, "markup_record_timeout", "超时关闭"),

    MARKUP_ORDER_PICKUP_TIMEOUT_CLOSE(114, "markup_record_pickup_timeout", "加价成功超时关闭"),

    MARKUP_ORDER_FAIL_DRIVER_PICKUP(115, "markup_record_fail_pickup", "加价失败，订单已被原价抢走"),

    MARKUP_ORDER_FAIL_USER_CANCEL(116, "markup_record_fail_user_cancel", "客户已取消订单"),

    MARKUP_DRIVER_REJECT_CLOSE(117, "markup_driver_reject_close", "加价接单成功-司机取消"),

    MARKUP_CHANGE_DRIVER_CLOSE(118, "markup_record_pickup_timeout", "加价接单成功-用户取消"),

    MARKUP_SUCCESS_DRIVER_PICKUP_FAIL(119, "markup_success_driver_pickup_fail", "客户同意加价，司机接单失败"),

    MARKUP_START_PK_ERROR(121, "markup_start_pk_error", "加价失败，订单开始pk"),

    MARKUP_ORDER_USER_INVITATION_DRIVER_OFFER_INVALID(122, "markup_order_user_invitation_driver_offer_invalid", "用户邀请，司机报价失效"),

    MARKUP_ORDER_USER_INVITATION_FAILED(123, "markup_order_user_invitation_failed", "用户同意司机加价，用户邀请失效"),


    // 虚拟号服务
    VIRTUAL_NUMBER_REPLACE_FAIL(200, "virtual_number_replace_fail", "虚拟号服务换绑失败"),

    VIRTUAL_NUMBER_UNBINDING_FAIL(201, "virtual_number_unbinding_fail", "虚拟号服务解绑失败"),

    VIRTUAL_NUMBER_CALL_LOG_NULL(202, "virtual_number_call_log_null", "虚拟号通话记录null"),


    PARAMETER_ERROR_ORDER_UUID(21101, "parameter_error_order_uuid", "参数错误order_uuid"),

    PARAMETER_ERROR_ORDER_ID(21101, "parameter_error_order_id", "参数错误order_id"),


    PARAMETER_ERROR_ORDER_SUBSET(21102, "parameter_error_order_subset", "参数错误order_subset"),

    PARAMETER_ERROR_LAT_LON(21103, "parameter_error_lat_lon", "参数错误lat_lon"),

    PARAMETER_ERROR_ORDER_DISPLAY_ID(21102, "parameter_error_order_display_id", "缺少order_display_id"),

    FACE_RECOGNITION_ERROR(21102, "face_recognition_error", "验证未通过，请重试"),

    LOCATION_ADDRESS_LIMIT_ERROR(21105, "svc.location_adress_limit_error", "你与装货地距离较远，请勿提前操作到达。若真实地址有变请联系客户修改地址或直接上报地址，让客户确认"),

    DELIVERY_PARAM_ERROR(10015, "delivery_param_error", "参数错误"),

    DELIVERY_PARAM_ERROR_CUSTOM(21003, "delivery_param_error_custom", "参数错误"),

    WAIT_FEE_ORDER_STATUS_ERROR(20001, "wait_fee_order_status_error", "您已完成装货或卸货，暂不能开始计时"),


    // pre_check
    QUESTION_ORDER_PRE_CHECK_ERROR(120, "question_pre_check_error", "该订单/司机不在灰度内"),
    QUESTION_HAS_NO_CHOICES_ERROR(121, "question_has_no_choices_error", "该订单无命中问题"),
    // ask question
    QUESTION_ORDER_STATUS_ERROR(122, "question_order_status_error", "订单已被抢走"),
    QUESTION_ORDER_CANCEL_ERROR(123, "question_order_fail_user_cancel", "订单已取消"),
    QUESTION_ORDER_USER_ALREADY_REPLY_OTHER_DRIVER(124, "question_order_user_already_reply_other_driver", "已有其他司机提问，请到订单页面查看更新信息"),
    QUESTION_ORDER_USER_ALREADY_REPLY(125, "question_order_user_already_reply", "用户已回复过该提问，请到订单页面查看更新信息"),
    QUESTION_ORDER_PLZ_WAITING_REPLY(126, "question_order_plz_waiting_reply", "您已发起过提问，请耐心等待用户回复"),
    QUESTION_ORDER_NON_EXIST(127, "question_order_non_exist", "问题记录不存在"),
    QUESTION_ORDER_REPLY_QUESTION_TYPE_ERROR(128, "question_order_reply_question_type_error", "回复问题question type与记录不一致"),
    QUESTION_ORDER_REPLY_USER_ID_ERROR(129, "question_order_reply_user_id_error", "回复问题user id与记录不一致"),
    QUESTION_ORDER_REPLY_ORDER_UUID_ERROR(130, "question_order_reply_order_uuid_error", "回复问题order uuid与记录不一致"),
    QUESTION_REQUEST_DUPLICATION(131, "question_request_duplication", "重复的请求,另一个请求正在处理中"),
    QUESTION_ASK_ERROR(132, "ask_question_error", "司机提问失败"),

    PARAM_ORDER_UUID_ERROR(21101, "param_order_uuid_error", "参数错误order_uuid"),

    PARAM_ORDER_SUBSET_ERROR(21102, "param_order_subset_error", "参数错误order_subset"),

    PARAM_LAT_LON_ERROR(21103, "param_lat_lon_error", "参数错误lat_lon"),

    PARAM_TYPE_ERROR(21104, "param_type_error", "参数错误type"),

    PORTERAGE_PRICE_RULE_NOT_EXIST(30001, "porterage_price_rule_not_exist", "计价规则不存在"),

    PORTERAGE_CALCULATE_PRICE_FAIL(30002, "porterage_calculate_price_fail", "搬运费计算失败"),

    PORTERAGE_START_WAIT_FEE_FAIL(10015, "porterage_start_wait_fee_fail", "已填写搬运费，无法开启等候费"),

    PORTERAGE_BILL_FEE_ERROR(30004, "porterage_bill_fee_fail", "搬运费计算失败"),

    PORTERAGE_IN_NODE_ERROR(10002, "porterage_in_node_error", "节点错误"),

    PARAM_ERROR1(21001, "param_error1", "参数错误"),

    PARAM_ERROR2(21002, "param_error2", "参数错误"),

    PORTERAGE_FILL_FEE_ERROR(30005, "porterage_fill_fee_fail", "搬运费填写错误"),

    PORTERAGE_CANNOT_MODIFY_ERROR(30006, "porterage_cannot_modify", "当前订单状态不可修改搬运信息"),

    PORTERAGE_MODIFY_AMOUNT_OVER_RANGE(30007, "porterage_modify_amount_over_range", "整单搬运费总价不可低于客户已支付金额"),

    NOT_SUPPORT_FILTER_TYPE(20005, "not_support_filter_type", "不支持的过滤类型"),
    ORDER_PORTERAGE_ORDER_ID_NULL(2000, "order_porterage_order_id_null", "未获取到orderId"),
    ORDER_PORTERAGE_USER_SOURCE(2001, "order_porterage_user_source", "用户来源"),

    RETURN_ORDER_PARAMETER_ERROR_QUESTION_ID(20006, "return_order_parameter_error_question_id", "返程单参数错误，问题ID不能为空"),
    RETURN_ORDER_PARAMETER_ERROR_DRIVER_ANSWER(20007, "return_order_parameter_error_driver_answer", "返程单参数错误，司机答案不能为空"),
    RETURN_ORDER_LOCK_ERROR(20008, "return_order_lock_error", "返程单保存司机答题记录接口获取锁失败"),

    // call_log
    CALL_LOG_DRIVER_PHONE_NO_NULL_ERROR(50001, "call_log_driver_phone_null", "司机虚拟号获取失败"),

    // rule
    RULE_DUPLICATION_ERROR(21105, "rule_duplication_error", "规则重复"),
    RULE_ORDER_RANGE_DUPLICATION_ERROR(21106, "rule_order_range_intersection_error", "规则金额区间重复"),
    SHARE_ORDER_USER_CANCEL(21212, "share_order_user_cancel", "很遗憾，你来晚了，该订单已过期"),
    SHARE_ORDER_HAS_PICK_UP(21210, "share_order_has_pick_up", "很遗憾，你来晚了，订单已被抢走"),
    SHARE_ORDER_SECURITY_VERIFICATION_FAILURE(21214, "share_order_security_verification_failure", "很遗憾，该订单走失了"),
    SHARE_ORDER_ERROR(21216, "share_order_error", "兜底页面"),
    SHARE_ORDER_NOT_FOUND(21218, "share_order_not_found", "订单不存在"),
    SHARE_ORDER_REACH_LIMIT(21220, "share_order_reach_limit", "您今日分享单量已达上限，请明日再来"),
    SHARE_ORDER_USER_CANCEL2(21213, "share_order_user_cancel", "订单已过期\n不支持分享"),
    SHARE_ORDER_HAS_PICK_UP2(21215, "share_order_has_pick_up", "该订单被抢走\n不支持分享"),

    MODIFY_ADDRESS_NONE_REPORT_RECORD(21120, "modify_address_none_report_record", "没有地址上报记录"),
    MODIFY_ADDRESS_VOICE_CALL_ERROR(21121, "modify_address_voice_call_error", "调用语音通知失败"),

    SYSTEM_CONFIG_NOT_EXIST(21107, "system_config_not_exist", "系统配置不存在"),

    LESS_MIN_DEPOSIT(20012, "less_min_deposit", "交纳保证金后可接单"),

    PARAMETER_ORDER_ID_ERR(9909, "svc.parameter.orderid.err", "ORDERID不能为空"),
    PARAMETER_APPID_ERR(9909, "svc.parameter.appid.err", "APPID不能为空"),
    PARAMETER_LABEL_NAME_ERR(9909, "svc.parameter.labelname.err", "LABELNAME不能为空"),
    PARAMETER_LABEL_VALUE_ERR(9909, "svc.parameter.labelvalue.err", "LABELVALUE不能为空"),
    PARAMETER_LABEL_LIST_ERR(9909, "svc.parameter.labellist.err", "LABELLIST不能为空"),

    // order deposit 司机订金
    ORDER_DEPOSIT_COS_UPDATE_NON_RECORD_ERROR(21108, "cos_update_not_find_record", "cos同步订金处理结果找不到相关记录"),
    ORDER_DEPOSIT_COS_UPDATE_NON_REFUND_RECORD_ERROR(21109, "cos_update_not_find_refund_record", "cos同步订金处理结果找不到相关退款记录"),

    ORDER_DEPOSIT_USER_CANCEL_NON_RECORD_ERROR(21111, "user_cancel_not_find_record", "用户取消处理订金找不到相关记录"),
    ORDER_DEPOSIT_DRIVER_CANCEL_NON_RECORD_ERROR(21112, "driver_cancel_not_find_record", "司机取消处理订金找不到相关记录"),
    ORDER_DEPOSIT_UPDATE_PAYMENT_NON_RECORD_ERROR(21113, "update_payment_not_find_record", "订金支付成功找不到相关记录"),
    ORDER_DEPOSIT_UPDATE_REFUND_NON_RECORD_ERROR(21114, "update_refund_not_find_record", "订金退款成功找不到相关记录"),
    ORDER_DEPOSIT_APPLY_COS_ERROR(21115, "apply_cos_error", "新增判责失败"),
    ORDER_DEPOSIT_PAY_ERROR(21116, "pay_deposit_error", "司机支付订金调用交易接口失败"),
    ORDER_DEPOSIT_QUERY_DRIVER_DEPOSIT_ERROR(21117, "query_deposit_error", "司机查询司机订金信息调用交易接口异常"),
    ORDER_DEPOSIT_PAY_REQUEST_DUPLICATION(21118, "pay_deposit_duplication", "支付订金重复的请求,另一个请求正在处理中"),

    APPEAL_HANDLE_NEW_VERSION_NON_OPEN(25001, "appeal_handle_new_version_non_open", "账单申诉新版本没有开城"),


    BILL_PUSH_TIME_NOT_EXISTS(40001, "svc.bill_push_time_not_exist", "发送账单时间不存在"),
    REQUEST_EXCEPTION(40002, "svc.request_exception", "异常请求"),
    STREAM_CONFIG_ERR(40003, "svc.stream_err", "stream配置异常"),

    CANCEL_REPORT_INFO_REPEAT_CREATE(90008, "CANCEL_REPORT_INFO_REPEAT_CREATE", "请勿重复报备"),
    // 不可重复
    FACE_COM_GET_ERROR(1300001, "FACE_COM_GET_ERROR", "人脸组件获取失败"),

    OFFLINE_DELIVERY_ORDER_ERROR(26001, "offline_delivery_order", "非离线订单"),
    DRIVER_OFFER_PRICE_TOO_LOW(22000, "driver_offer_price_too_low", "请勿低于订单原价x元"),

    DRIVER_OFFER_PRICE_TOO_HIGH(22001, "driver_offer_price_too_high", "修改价格与原价相差太大，不支持修改"),

    PHONE_NEGOTIATION_DRIVER_NOT_CONTACTED_USER(22002, "phone_negotiation_driver_not_contacted_user", "请先联系货主沟通一致后再接单"),

    ONLINE_NEGOTIATION_DRIVER_PICK_UP_ERROR(22003, "phone_negotiation_driver_not_contacted_user", "请点击【直接接单】按钮原价接单"),

    NEGOTIATION_ORDER_START_PK(22004, "negotiation_order_start_pk", "报价失败，已有其他司机直接接单"),

    // 司机改价异常
    ADJUST_ORDER_PRICE_APPLY_USER_UN_REPLY(22005, "adjust_order_price_apply_user_un_reply", "客户未同意改价，请提醒客户操作。现在卸货完成视为放弃改价，是否继续"),

    RECEIPT_REPORT_LIMIT(20001, "receipt_report_limit", "请勿在短时间内操作，确保真实送回回单时再操作"),

    RECEIPT_USER_CONFIRMED(20002, "receipt_user_confirmed", "用户已确认回单"),

    // 包车开始计时提示异常
    PREPARE_LOADING_CHARTERED_START_WARN(22006, "prepare_loading_chartered_start_warn", "开始卸货包车行程计时开始确认"),
    // 包车结束计时提示异常
    START_UNLOADING_CHARTERED_END_WARN(22007, "start_unloading_chartered_end_warn", "开始卸货包车行程计时结束确认");
    private Integer ret;
    private String code;
    private String msg;

    BizCode(Integer ret, String code, String msg) {
        this.ret = ret;
        this.code = code;
        this.msg = msg;
    }

    public Integer getRet() {
        return ret;
    }


    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public BizException getException(Throwable throwable) {
        return new BizException(this.getRet(), this.getMsg(), throwable);
    }

    public BizException getException() {
        return new BizException(this.getRet(), this.getMsg());
    }

    public BizException getException(String msg) {
        return new BizException(this.getRet(), msg);
    }

    public BizException getException(Object data) {
        return new BizException(
                this.getRet(), this.getMsg(), Objects.toString(data, ""));
    }

    public BizException getException(String msg, Object data) {
        return new BizException(this.getRet(), msg, data);
    }

    public BaseResult<Object> getRsp() {
        return new BaseResult<>(this.getRet(), this.getMsg(), null);
    }

    public BaseResult<Object> getRsp(String msg) {
        return new BaseResult<>(this.getRet(), msg, null);
    }


    private void setRet(Integer ret) {
        this.ret = ret;
    }

    private void setCode(String code) {
        this.code = code;
    }

    private void setMsg(String msg) {
        this.msg = msg;
    }
}
